#include <stdio.h>

int sumOfSubarrays(int arr[], int size) {
    int sum = 0;
    
    for (int i = 0; i < size; i++) {
        for (int len = 1; len <= size; len += 2) {
            if (i + len > size) {
                break;
            }
            
            for (int j = i; j < i + len; j++) {
                sum += arr[j];
            }
        }
    }
    
    return sum;
}

int main() {
    int size;
    
    printf("请输入数组的大小：");
    scanf("%d", &size);
    
    int arr[size];
    
    printf("请输入数组元素：");
    for (int i = 0; i < size; i++) {
        scanf("%d", &arr[i]);
    }
    
    int sum = sumOfSubarrays(arr, size);
    
    printf("所有奇数长度子数组的和为：%d\n", sum);
    
    return 0;
}